<?php
namespace fastphp;
class Model extends Db {
    protected string $_model;
    protected string $_table;

    function __construct() {
        if (empty($this->_table)){
            // 转换模型+Model为模型名称
            $class_name = get_class($this);
            $class_name_split = explode('\\',$class_name);
            // 获取对象所属类的名称
            $this->_model = $class_name_split[count($class_name_split)-1];
            $this->_model = rtrim($this->_model, 'Model');

            // 数据库表名与类名一致
            $this->_table = strtolower($this->_model);
        }
        parent::__construct($this->_table);
    }

    function __destruct() {
    }
}